package com.hsyt.pms.api.common;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;

/**
 * @Description: TODO
 * @author wangze@hsyuntai.com
 * @date 2019年2月12日 下午2:45:51
 */
public class PageParam implements Serializable {

	private static final long serialVersionUID = 3938095740389970783L;

	private Integer pageNumber;//第几页
	private Long offset = 0L;
	private Integer pageSize = 10;
	private String order;
	private String sort;
	public Integer getPageNumber() {
		return pageNumber;
	}
	public void setPageNumber(Integer pageNumber) {
		this.pageNumber = pageNumber;
	}
	public Long getOffset() {
		return offset;
	}
	public void setOffset(Long offset) {
		this.offset = offset;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	public String getSort() {
		return sort;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

	public static void initPageDto(PageParam pageDto) {
		if(pageDto != null) {
			if(pageDto.pageSize<=0 || pageDto.offset < 0L){
				pageDto.setPageSize(10);
				pageDto.setOffset(0L);
			}
		}
	}
}
